package cn.neusoft.luofa603.yuejian_29.activity;

import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.TextView;

import com.squareup.picasso.Picasso;

import cn.neusoft.luofa603.yuejian_29.Global;
import cn.neusoft.luofa603.yuejian_29.R;
import cn.neusoft.luofa603.yuejian_29.bean.Course;

import static cn.neusoft.luofa603.yuejian_29.R.id.iv_return;

public class CourceInfoActivity extends AppCompatActivity {
    private TextView course_name,introduction,star_date,end_date,course_price,buy_num,total_price;
    private Button goumai,iv_retun;
    private ImageButton course_collect;
    private ImageView bt_less,bt_more,course_img;
    public Course course;
    private int num,c_price;
    private String price;
    private Double sum;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_courceinfo);
        initviews();
        innitEvents();
        intData();
    }
    public void initviews(){
        course_name=(TextView)findViewById(R.id.course_name);
        introduction=(TextView)findViewById(R.id.introduction);
        star_date=(TextView)findViewById(R.id.star_date);
        end_date=(TextView)findViewById(R.id.end_date);
        course_price=(TextView)findViewById(R.id.course_price);
//        buy_num=(TextView)findViewById(R.id.buy_num);
//        total_price=(TextView)findViewById(R.id.total_price);
        iv_retun=(Button)findViewById(iv_return);
        goumai=(Button)findViewById(R.id.goumai);
        course_collect=(ImageButton)findViewById(R.id.course_collect);
//        bt_less=(ImageView)findViewById(R.id.bt_less);
//        bt_more=(ImageView)findViewById(R.id.bt_more);
        course_img=(ImageView)findViewById(R.id.course_img);


    }

    public void innitEvents(){
        iv_retun.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                finish();
            }
        });
        course_collect.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {

            }
        });
        goumai.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(CourceInfoActivity.this,BuyCourseActivity.class);
                Bundle bundle = new Bundle();
                bundle.putSerializable("Course",course);
                intent.putExtras(bundle);
                startActivity(intent);
            }
        });

    }
    public void intData(){

        getCourseInfo();

    }
    public void getCourseInfo(){
        final Bundle bundle=getIntent().getExtras();
        course=(Course)bundle.getSerializable("Course");
        course_name.setText(course.getCourse_name());
        introduction.setText(course.getIntroduction());
        star_date.setText(course.getStart_date());
        end_date.setText(course.getEnd_date());
//        price=(course.getCourse_price());
        course_price.setText(course.getCourse_price());
        Picasso.with(this).load(Global.PIC+course.getThumb()).into(course_img);
    }

}
